home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000070_icon-group-sender_Mon Oct 14 07:49:46 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  9KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9EEm9w06924
  4.     for icon-group-addresses; Mon, 14 Oct 2002 07:48:09 -0700 (MST)
  5. Message-Id: <200210141448.g9EEm9w06924@baskerville.CS.Arizona.EDU>
  6. From: "Andrew Hamm" <ahamm@mail.com>
  7. X-Newsgroups: comp.lang.icon
  8. Subject: Re: Icon Wish List
  9. Date: Sun, 13 Oct 2002 00:46:52 +1000
  10. X-Priority: 3
  11. X-MSMail-Priority: Normal
  12. X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
  13. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
  14. To: icon-group@cs.arizona.edu
  15. Errors-To: icon-group-errors@cs.arizona.edu
  16. Status: RO
  17.  
  18. Shmuel (Seymour J.) Metz wrote:
  19. > [STUFF]
  20. >
  21.  
  22. I don't think you've understood what I've said. Perhaps I'm not using the
  23. correct terminology... let me deal with your points one by one.
  24.  
  25. >> Since Icon is completely free with variable types and call arguments,
  26. >> it follows that class members should not be typed,
  27. >
  28. > No. The class is the type.
  29. >
  30.  
  31. look at this:
  32.  
  33.     procedure thing(arg)
  34.         local lcl
  35.  
  36. to me, "arg" and "lcl" are variables; the dynamically allocated objects
  37. which they may refer to at any point during execution have type (traditional
  38. Icon types being string, numerics, tables etc), but "arg" and "lcl" do not
  39. have a declared type. Of course the allocated objects will have type; as you
  40. say, the class will be the type of the allocated object currently referred
  41. to by arg or lcl, but still, "arg" and "lcl" do not have a declared type and
  42. it is contrary to the current design of Icon to declare type for these
  43. variables - ie the named variables. Clearly the referred objects will have
  44. class type. It does violence to Icon to suggest that variables be declared
  45. with type, such as:
  46.  
  47.     local lcl: someClass
  48.  
  49. and to me, it follows that class members should not be declared with type
  50. either. Neither should method arguments.... read on.
  51.  
  52. >> and overloaded methods do
  53. >> not make sense either
  54. >
  55. > They make perfect sense if you allow subclasses and such.
  56. >
  57.  
  58. I said "overloaded" not "overridden". An example of an overloaded method is:
  59.  
  60. class ClassA {
  61.     draw(int x, int y);
  62.     draw(Coord xy);
  63. }
  64.  
  65. Now, objects of type ClassA may have these two calls made:
  66.  
  67.     anA.draw(10, 20);
  68.  
  69. or
  70.  
  71.     anA.draw(new Coord(10, 20)); // or equivalent
  72.  
  73. Here, the draw method is "overloaded" within the class to support different
  74. calls providing that the argument signatures are sufficiently unambiguous
  75. within the language rules.
  76.  
  77. In languages supporting overloaded methods, they require the argument type
  78. and possibly the return type to be declared for the methods, and the
  79. "signatures" of the methods must be sufficiently distinct to allow the
  80. compiler to choose the correct method when it knows the count and types of
  81. all the values being provided to the method call. Since Icon supports
  82. untyped arguments, default null values for unprovided arguments, quiet
  83. discarding of excess arguments and finally explicit variable argument lists
  84. with the trailing arg[] syntax, it follows that Object Icon would most
  85. naturally support one method of one name *per class* with normal Icon-style
  86. argument declaration and invocation. However I am not saying that Object
  87. Icon should prevent *overriding* of methods in sub-classes. I thought my
  88. discussion clearly showed cognisance of sub-classes and *overridden*
  89. methods.
  90.  
  91. >> one name, one method
  92. >
  93. > Too restrictive, and destroys some of the value of OO programming.
  94. >
  95.  
  96. No, it doesn't. Icon currently supports variable argument lists in procedure
  97. calls, and it's a common technique to detect the differing arguments
  98. provided and perform a variant action depending on the arguments passed.
  99. Further, any method which cared to handle different args differently can
  100. easily examine the type of the arguments and choose to interpret them
  101. appropriately. For example, C++ might require you to declare
  102.  
  103.     draw(int x, int y) { .... }
  104.  
  105. and
  106.  
  107.     draw(xy Coord) { .... }
  108.  
  109. but Object Icon can easily be coded to detect the types of the args and deal
  110. with it accordingly. eg
  111.  
  112.     procedure draw(x, y)
  113.  
  114.         if numeric(\x) & numeric(\y) then ....
  115.         else if type(x) == "Coord" & /y then ....
  116.         else
  117.  
  118. OK, so that sample is not perfect, but a few minutes of real thought would
  119. make it most usable. Sample given for illustration only.
  120.  
  121. >> What about member privacy? With the 1 file, 1 class model, it does
  122. >> become possible to add a "private" keyword for class methods,
  123. >> members and statics. If marked as private, the member is not visible
  124. >> outside the file. However, that does not fit at all with the dynamic
  125. >> typing of Icon.
  126. >
  127. > Yes it does. Don't confuse the scope of the name with the lifetime of
  128. > the object.
  129. >
  130.  
  131. Well, no it doesn't. You need to consider how it might be implemented. If
  132. ClassA declared a private member M, but ClassB declared a public member M,
  133. consider this situation:
  134.  
  135. class ClassC ........
  136.  
  137. procedure method1(arg)
  138.     ....
  139.     if arg.M > 10 then .....
  140.  
  141. now, how can the compiler determine that arg.M is legal? Depending on what
  142. is passed in, arg.M may or may not be legal depending on the current dynamic
  143. type of the value that arg refers to. The only way to solve this is with a
  144. runtime check which cross-references the current dynamic type with the
  145. visibility of M in relation to the context using it. Did you say "Bletch!" ?
  146. I say bletch to such horrific runtime tests... I want my scripts to complete
  147. today, thank-you very much.
  148.  
  149. >> However,
  150. >> that does not fit at all with the dynamic typing of Icon.
  151. >
  152. > It fits in perfectly. All that changes is that there are more possible
  153. > types.
  154. >
  155.  
  156. The increased set of possible types is not related to the necessary compiler
  157. and/or runtime code required to enforce scoping rules.
  158.  
  159. >> How do you know the type of a particular variable at any one time?
  160. >
  161. > The same way as in any other language with dynamic types.
  162. >
  163.  
  164. I am aiming more for compile-type checking. I spit on runtime checking of OO
  165. rules. If you want heavy rules, use a language which can resolve all the
  166. nonsense at compile time. Icon has never demanded specific declarations, and
  167. an Object Icon should retain that freedom and simplicity. It's about time
  168. that programmers learned to respect good programming practices. I am
  169. disgusted at the mess we lovingingly call C++ version 3 with STL and
  170. standards approval. What a disaster, and all that legalise rubbish just
  171. because programmers continue to be lazy and clumsy and enjoy shooting
  172. themselves in the foot.
  173.  
  174. >> To do this "properly" on UNIX, the compiler could probably write to
  175. >> a tmp file (not linked into a directory) and then hand the open file
  176. >> handles off to a cooperating iconx which can slurp up the icode from
  177. >> the tmp file handles and then close them, resulting in their
  178. >> deallocation.
  179. >
  180. > Bletch!
  181. >
  182.  
  183. I'm only suggesting a method to add
  184.  
  185. #!/usr/bin/icon
  186.  
  187. capabilities easily into Icon. Since the current implementation is neatly
  188. split into a compiler/linker and a separate runtime, it's mere mechanics to
  189. add #! to Icon, without requiring the merging of icont and iconx just
  190. because "it's more elegant" to merge them, or too "bletchy" to use a dirty
  191. trick. Why burden the runtime with the baggage of the compiler? My
  192. suggestion is merely pragmatic, and nobody needs to see how much steam and
  193. oil is spraying around in the engine room.
  194.  
  195. However, there is tantalising merit in allowing Icon programs to support
  196. some kind of "eval" statement just like Perl or shells do; this would
  197. require access to the compiler from the runtime...
  198.  
  199. Ultimately, you have to remember that Icon is very dynamically typed, very
  200. simple in it's scoping, and it doesn't follow convention. Please let's not
  201. burden Icon or a hypothetical Object Icon with fashionable or politically
  202. correct ideas about how OO must be implemented. C++ has shown the folly of
  203. designing a language to the point that only a lawyer can fully understand
  204. all the rules. Perl has shown quite clearly that lack of enforced
  205. encapsulation rules does not cause a mass outbreak of bugs. I've collected
  206. dozens of classes out of CPAN and am happily using them, completely ignorant
  207. of the internal mechanics and totally unfazed by the lack of privacy for the
  208. class members. If I start fishing around inside the class, messing around
  209. with class members beyond that described in the doco, then I've only got
  210. myself to blame when my code blows up in my face. Same goes for everyone
  211. else.
  212.  
  213.  
  214.